# -*- coding: utf-8 -*-

from muti import *
import matplotlib.pyplot as plt

state = State()
state.p_pos = np.random.random((state.p_n, 2)) * 2 - 1
# state.p_pos = np.array(
#     [[-0.4543597508425903, 0.450661282995239], [0.7675516806895089, 0.24700733549505016], [-0.4263227169004855, 0.38153272306402264]]
# )
print(state.p_pos.tolist())

fig, ax = plt.subplots()
width = 5
ax.set_xlim(-width, width)
ax.set_ylim(-width, width)
ax.set_aspect(1)

angle = SolveState1(state, 2)

def DrawCircle(o, r, ls):
    t = np.linspace(0, np.pi*2, 100)
    x = r * np.cos(t)
    x[:] += o[0]
    y = r * np.sin(t)
    y[:] += o[1]
    plt.plot(x, y, ls)

plt.scatter([state.e_pos[0]], [state.e_pos[1]], c="r")
plt.scatter(state.p_pos[:, 0], state.p_pos[:, 1], c="b")

for i in range(state.p_n):
    o, r = ACircle(state.p_pos[i], state.e_pos, state.p_vmax[i] / state.e_vmax)
    DrawCircle(o, r, "b-")

angle_lst = SolveState3(state)
for i in range(state.p_n):
    x, y = Rotate(state.p_pos[i], state.e_pos, angle_lst[i])
    state.p_pos[i] = [x, y]

for i in range(state.p_n):
    o, r = ACircle(state.p_pos[i], state.e_pos, state.p_vmax[i] / state.e_vmax)
    DrawCircle(o, r, "r-")

plt.show()
